package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"system/api-getaway/pkg"
)

func Upload(r *gin.Context) {
	
	file, err := r.FormFile("image")
	if err != nil {
		r.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "获取文件失败",
		})
		return
	}

	// 调用上传函数
	uploadURL, err := pkg.Upload(file)
	if err != nil {
		r.JSON(http.StatusOK, gin.H{
			"code":    200,
			"message": "图片上传成功",
			"data":    uploadURL,
		})
	}
}
